﻿using Symmetry.PluginSupport;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace Plugins1
{
    public sealed partial class PerspectiveEditor : UserControl, ICustomEditor
    {
        public PerspectiveEditor()
        {
            this.InitializeComponent();
        }

        public string Description
        {
            get
            {
                return "Manipulate perspective on target";
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string FriendlyName
        {
            get
            {
                return "Perspective Editor";
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void SetObject(object target)
        {
            UpdateBindings(target);
        }

        PlaneProjection pp = new PlaneProjection();

        /// <summary>
        /// For given target, if fx element, create a new perspective trans and set binding on its x prop to slider.
        /// </summary>
        /// <param name="target"></param>
        private void UpdateBindings(object target)
        {

            Target = target;
        }

        public object Target { get; set; }

        private void sliderX_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
        {
            if (Target == null) return;

            FrameworkElement el = Target as FrameworkElement;
            if (el == null) return;

            el.Projection = new PlaneProjection() { RotationX = sliderX.Value };
        }




        public string UniqueID
        {
            get { return "BFA57307-F921-4F6B-BD60-AFE68B666015"; }
        }
    }


}
